#ifndef _DB_H
#define _DB_H

class LRUCache;
class Bitcask;
class BtreeIndex;

#define INSERT 0x1
#define UPDATE 0x2
#define UPSERT (INSERT|UPSERT) //0x3

#define NO_CACHE 0
#define LRU_CACHE 1
#define FORCE_CACHE 2

#define NO_PERSISTANT 0
#define PERSISTANT 1

#define CLOSE_NO_SAVE_CACHE 0
#define CLOSE_SAVE_CACHE 1

class PangDBCore
{
public: 
    int Open(char *path, int persistant_mode, int cache_mode, int close_mode);
    int Close();
    int Set(char *key, int key_size, char *val, int val_size, int mode, bool fsync = false);
    int Get(char *key, int key_size, char **val_large, char *val, int val_size_limit, int *val_size);
    int Delete(char *key, int key_size, bool fsync = false);
    void FreeVal(void *ptr);

private:
    char cache_type;
    char persistant;
    char close_save_cache;
    int compact_hours;

    u64 mem_limit;

    LRUCache* cache;
    Bitcask* bitcask;
    BtreeIndex* index;
};


#endif
